package goqueryimport// Each iterates over a Selection object, executing a function for each// matched element. It returns the current Selection object. The function// f is called for each element in the selection with the index of the// element in that selection starting at 0, and a *Selection that contains// only that element.func ( *Selection) ( func(int, *Selection)) *Selection {for , := range .Nodes { (, newSingleSelection(, .document)) }return}// EachIter returns an iterator that yields the Selection object in order.// The implementation is similar to Each, but it returns an iterator instead.func ( *Selection) () iter.Seq2[int, *Selection] {returnfunc( func(int, *Selection) bool) {for , := range .Nodes {if !(, newSingleSelection(, .document)) {return } } }}// EachWithBreak iterates over a Selection object, executing a function for each// matched element. It is identical to Each except that it is possible to break// out of the loop by returning false in the callback function. It returns the// current Selection object.func ( *Selection) ( func(int, *Selection) bool) *Selection {for , := range .Nodes {if !(, newSingleSelection(, .document)) {return } }return}// Map passes each element in the current matched set through a function,// producing a slice of string holding the returned values. The function// f is called for each element in the selection with the index of the// element in that selection starting at 0, and a *Selection that contains// only that element.func ( *Selection) ( func(int, *Selection) string) ( []string) {returnMap(, )}// Map is the generic version of Selection.Map, allowing any type to be// returned.func [ any]( *Selection, func(int, *Selection) ) ( []) { = make([], len(.Nodes))for , := range .Nodes { [] = (, newSingleSelection(, .document)) }return}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.